/**
  ******************************************************************************
  * @file           : vehicle.c
  * @author         : SunYuLong
  * @brief          : 车辆
  * @date           : 2024/12/13
  ******************************************************************************
**/


#include "../include/vehicle.h"



/**
* @CreateTime 2024/12/13
* @Author yulongsun
* @brief 计算停车费用函数
* @param vehicle 车辆信息
* @return 返回计算出的停车费用（单位：元）
*/
double count_fee(Vehicle *vehicle)
{
    if (vehicle->status == 0)
    {
        printf("该车辆未停车！");
        return 0;
    }

    if (vehicle->entry_time > vehicle->exit_time)
    {
        printf("该车辆停车时间有误，系统错误！");
        return 0;
    }

    double park_time = vehicle->exit_time - vehicle->entry_time;

    if (vehicle->vehicle_type == 1)
    {
        return park_time * TRUCK_PARK_RULE;
    }

    return park_time * CAR_PARK_RULE;
}

